import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('GlobalVar')
class GlobalVar {
    private static _instance: GlobalVar = null;
    private Coins: number = 0;
    private CardsInSlot: Node[] = [];
    private ClassicModeLevel: number = 1;
    public SERVER_ADDRESS = 'http://150.158.93.73:30000';   //服务器地址
    public WEBSOCKET_ADDRESS = 'ws://150.158.93.73:9090';   //websocket地址
    public noticeState = false; //公告显示状态(true代表显示过了，之后不再显示；false代表要显示一次（当不隐藏时，每次打开游戏只显示一次）)
    public avatarSpriteCache = null;
    public nicknameCache = null;
    public avatarUrlCache = null;
    public CardFrameUsed = null;    //当前使用中的皮肤id
    public Userid = null;

    public static getInstance(): GlobalVar {
        if (this._instance == null) {
            this._instance = new GlobalVar();
        }
        return this._instance;
    }
    
    public getCoins(): number {
        return this.Coins;
    }
    public setCoins(value: number): void {
        this.Coins = value;
    }
    public getCardInSlot(): Node[] {
        return this.CardsInSlot;
    }
    public clearCardInSlot() {
        this.CardsInSlot = [];
    }
    public setClassicModeLevel(level: number) {
        this.ClassicModeLevel = level;
    }
    public getClassicModeLevel(): number {
        return this.ClassicModeLevel;
    }
}
export const GLOBALVar = GlobalVar.getInstance();


